package cn.stylefeng.guns.modular.business.app.service.impl;

import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.modular.business.app.controller.dto.DocumentTypeCodeDTO;
import cn.stylefeng.guns.modular.business.app.service.DocumentTypeCodeService;
import cn.stylefeng.guns.sys.modular.user.entity.DocumentTypeCode;
import cn.stylefeng.guns.sys.modular.user.mapper.DocumentTypeCodeMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class DocumentTypeCodeServiceImpl extends ServiceImpl<DocumentTypeCodeMapper, DocumentTypeCode> implements DocumentTypeCodeService {
    /**
     * 获取证件类型编码
     */
    @Override
    public ResponseData<DocumentTypeCodeDTO> getDocumentTypeCode() {
        //获取全部证件类型编码
        List<DocumentTypeCode> codeList = this.baseMapper.selectList(null);
        //然后将数据转换为响应格式返回
        return ResponseData.success(codeList.stream().map(s -> {
            DocumentTypeCodeDTO dto = new DocumentTypeCodeDTO();
            BeanUtils.copyProperties(s, dto);
            return dto;
        }).collect(Collectors.toList()));
    }
}
